package sketch.shape.arrow;

import java.awt.Graphics2D;

import sketch.shape.Shape;
import sketch.shape.geom.prim.Line;
import sketch.shape.geom.prim.Point;

public class ArrowHead extends Shape {

	private Point head;

	private Point tail;

	public ArrowHead() {

	}

	public Point getCenter() {
		return getHead().linearInterpolate(getTail(), 0.5);
	}

	public Point getHead() {
		return head;
	}

	public void setHead(Point head) {
		this.head = head.clone();
	}

	public Point getTail() {
		return tail;
	}

	public void setTail(Point tail) {
		this.tail = tail.clone();
	}

	public Line getShaft() {
		return new Line(getTail(), getHead());
	}

	public void drawComponent(Graphics2D g2) {
		super.drawComponent(g2);
		g2.drawLine(getHead().intX(), getHead().intY(), getTail().intX(), getTail().intY());
		drawHead(g2);
	}

	protected void drawHead(Graphics2D g2) {
		int D = 3;
		g2.fillOval(getHead().intX()-D, getHead().intY()-D, 2*D, 2*D);
	}

	public java.awt.Shape getBound(double GAP) {
		return new Line(getHead(), getTail()).getBound(GAP);
	}

	public String[][] getFieldValues() {
		return new String[][] {
				{ "HeadPoint", getHead().toString() },
				{ "TailPoint", getTail().toString() },
		};
	}

}
